fix: resolve Terraform variable validation cross-reference error#304
Merged
fix: resolve Terraform variable validation cross-reference error#304
Conversation
Move vault name word validation from variables.tf to main.tf to comply with Terraform requirement that variable validations can only reference the variable itself. Changes: - Remove invalid cross-variable reference in vault_name validation - Add vault name word validation logic using locals in main.tf - Add runtime validation with clear error messages for restricted words - Preserve vault_name_validation_bypass functionality - Maintain backward compatibility Fixes terraform init error: 'The condition for variable vault_name can only refer to the variable itself, using var.vault_name' Co-authored-by: Luis M. Gallardo D. <lgallard@users.noreply.github.com>
Owner
Author
Validation Results ✅I've tested this PR with the exact user configuration from issue #292 and confirmed the fix works correctly. Test ConfigurationUsed the example from issue #292 comment: module "aws_backup_example" {
source = "lgallard/backup/aws"
vault_name = "EC2"
iam_role_name = "aws-backup-plan-EC2-role"
plan_name = "EC2"
}Test Scenarios & Results✅ Scenario 1: Success Path (vault name without restricted words)
✅ Scenario 2: Validation Path (vault name with restricted word)Changed
Key Findings
RecommendationThis PR is ready to merge. The fix successfully resolves issue #292 while maintaining all existing functionality and security validations. |
- Add null provider to required_providers in versions.tf (>= 3.0) - Fix trailing whitespace in main.tf - Required for null_resource.vault_name_validation used in runtime validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the Terraform variable validation error reported in issue #292.
Problem
Users reported terraform init failures with the error:
This occurred because the vault_name validation block referenced another variable (
var.vault_name_validation_bypass), which violates Terraform's validation constraints.Solution
Changes
Testing
The original user configuration should now work:
Backward Compatibility
vault_name_validation_bypassstill works as intendedFixes #292
🤖 Generated with Claude Code